﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Pavilion.GameTools;

namespace Pavilion.Locks
{
    public class CharacterInputLock : ILock
    {
        public CharacterInput Input { get; set; }
        public bool IsPressed { get; set; }

        public void Deserialize(XElement lockElement, string resourceName)
        {
            Input = (CharacterInput)Enum.Parse(typeof(CharacterInput), lockElement.Attribute("Input").Value);
            IsPressed = bool.Parse(lockElement.Attribute("IsPressed").Value);
        }

        public XElement Serialize()
        {
            XElement lockElement = new XElement("Lock");

            lockElement.Add(new XAttribute("Input", Input));
            lockElement.Add(new XAttribute("IsPressed", IsPressed));

            return lockElement;
        }

        public LockMonitorBase CreateLockMonitor(GameItem gameItem)
        {
            return new CharacterInputLockMonitor(this);
        }

        public override string ToString()
        {
            return this.GetType().Name;
        }
    }
}
